import request from '@/config/axios'

export interface EvalMonitoringDataVO {
  id?: number
  planId: number
  monitoringType: string
  monitoringContent: string
  monitoringTime: string
  monitoringResult: string
  monitoringStatus: number
  monitoringComments?: string
  createTime?: Date
}

export interface EvalMonitoringDataPageReqVO extends PageParam {
  planId?: number
  monitoringType?: string
  monitoringStatus?: number
  monitoringTime?: string[]
  createTime?: Date[]
}

export interface EvalMonitoringReportVO {
  planId: number
  planName: string
  totalMonitoringCount: number
  normalCount: number
  exceptionCount: number
  warningCount: number
  monitoringRate: number
  lastMonitoringTime?: string
}

// 查询监控数据分页
export const getMonitoringDataPage = (params: EvalMonitoringDataPageReqVO) => {
  return request.get({ url: '/eval/monitoring-data/page', params })
}

// 查询监控数据详情
export const getMonitoringData = (id: number) => {
  return request.get({ url: '/eval/monitoring-data/get?id=' + id })
}

// 新增监控数据
export const createMonitoringData = (data: EvalMonitoringDataVO) => {
  return request.post({ url: '/eval/monitoring-data/create', data })
}

// 修改监控数据
export const updateMonitoringData = (data: EvalMonitoringDataVO) => {
  return request.put({ url: '/eval/monitoring-data/update', data })
}

// 删除监控数据
export const deleteMonitoringData = (id: number) => {
  return request.delete({ url: '/eval/monitoring-data/delete?id=' + id })
}

// 导出监控数据
export const exportMonitoringData = (params: EvalMonitoringDataPageReqVO) => {
  return request.download({ url: '/eval/monitoring-data/export-excel', params })
}

// 根据计划ID获得监控数据列表
export const getMonitoringDataListByPlanId = (planId: number) => {
  return request.get({ url: '/eval/monitoring-data/list-by-plan?planId=' + planId })
}

// 根据监控类型获得监控数据列表
export const getMonitoringDataListByType = (monitoringType: string) => {
  return request.get({ url: '/eval/monitoring-data/list-by-type?monitoringType=' + monitoringType })
}

// 根据状态获得监控数据列表
export const getMonitoringDataListByStatus = (monitoringStatus: number) => {
  return request.get({ url: '/eval/monitoring-data/list-by-status?monitoringStatus=' + monitoringStatus })
}

// 获取监控统计信息
export const getMonitoringStatistics = (): Promise<any> => {
  return request.get({ url: '/eval/monitoring-data/statistics' })
}

// 获取监控报表
export const getMonitoringReport = (planId?: number): Promise<EvalMonitoringReportVO[]> => {
  const params = planId ? { planId } : {}
  return request.get({ url: '/eval/monitoring-data/report', params })
}

// 获取实时监控数据
export const getRealTimeMonitoringData = (planId: number) => {
  return request.get({ url: '/eval/monitoring-data/real-time?planId=' + planId })
}

// 处理监控异常
export const handleMonitoringException = (id: number, handleComments: string) => {
  return request.put({ url: '/eval/monitoring-data/handle-exception', data: { id, handleComments } })
}

// 确认监控数据
export const confirmMonitoringData = (id: number) => {
  return request.put({ url: '/eval/monitoring-data/confirm?id=' + id })
}

// 获取监控预警信息
export const getMonitoringAlerts = () => {
  return request.get({ url: '/eval/monitoring-data/alerts' })
}
